<template>
  <div >
    <div class="shezhi" style="background-image: url(./img/beijing_01.jpg);">
        <div class="shezhi1">
            <van-nav-bar title="注册" left-text="返回"  left-arrow @click-left="onClickLeft"  class="shezhitu-1" background="transparent"/>
        </div>
        <div class="shezhi2">
                <van-form @submit="onSubmit">
              <van-field
                v-model="username"
                name="用户名"
                label="用户名"
                placeholder="用户名"
                :rules="[{ required: true, message: '请填写用户名' }]"
              />
              <van-field
                v-model="password"
                type="password"
                name="密码"
                label="密码"
                placeholder="密码"
                :rules="[{ required: true, message: '请填写密码' }]"
              />
              <div>
                  <van-field readonly clickable name="calendar" :value="value" label="请选择出生日期" placeholder="点击选择日期" @click="showCalendar = true"/>
                  <van-calendar v-model="showCalendar" @confirm="onConfirm"  :min-date="minDate" :max-date="maxDate"/>
              </div>
              <div>
                <van-field readonly clickable name="area" :value="value1" label="地区选择" placeholder="点击选择省市区" @click="showArea = true"/>
                <van-popup v-model="showArea" position="bottom">
                  <van-area :area-list="areaList" @confirm="onConfirm1" @cancel="showArea = false"/>
                </van-popup>
              </div>
              <van-checkbox v-model="checked">请勾选同意协议</van-checkbox>
              <div style="margin: 0.16rem;">
                <van-button round block type="info" native-type="submit" :disabled="!checked">注册</van-button>
              </div>

            </van-form>
        </div>
    </div>
  </div>
</template>

<script>
import { areaList } from '@vant/area-data';
export default {
  data() {
    return {
      username: '',
      password: '',
      checked: false,
      value: '',
      showCalendar: false,
      value1: '',
      showArea: false,
      areaList,
      minDate: new Date(1900, 0, 1),
      maxDate: new Date(2022, 0, 31),
    };
  },
  methods: {
    onSubmit(values) {
      console.log('submit', values);
      alert("注册成功一秒后跳转至登录页")
      setTimeout(() => {
        this.$router.push("/denglu")
      }, 1000);
      
    },
    onClickLeft() {
      this.$router.go(-1)
    },
    onConfirm(date) {
      this.value = `${date.getMonth() + 1}/${date.getDate()}`;
      this.showCalendar = false;
    },
    onConfirm1(values) {
      this.value1 = values
        .filter((item) => !!item)
        .map((item) => item.name)
        .join('/');
      this.showArea = false;
    },
  },
};
</script>

<style scoped>
.shezhi{
   
    background-repeat: no-repeat;
    background-size: 100%;
    display: flex;
    flex-wrap: wrap;
    width: 100%;
    height: 100%;
}
.shezhi1{
    width: 100%;
}
.shezhi2{
    overflow: auto;
    width: 100%;
    height: 100%;
}
.van-nav-bar{
  background: transparent;
}
</style>
